import request from '@/services/axios/index';
import { LoginUser, RegisterUser } from './type';
// 登录
export const login = (data: LoginUser) => {
  return request({
    method: 'post',
    url: '/api/user/login',
    data,
  });
};
// 验证码
export const getCaptcha = (data: { to: string }) => {
  return request({
    method: 'post',
    url: '/api/user/register-captcha',
    data,
  });
};
// 注册
export const register = (data: RegisterUser) => {
  return request({
    method: 'post',
    url: '/api/user/register',
    data,
  });
};
// 修改密码
export const updatePassword = (data: Record<any, string>) => {
  return request({
    method: 'post',
    url: '/api/user/update_password',
    data,
  });
};

// 修改用户信息
export const updateUserInfo = (data: Record<any, string>) => {
  return request({
    method: 'post',
    url: '/api/user/update',
    data,
  });
};
// 获取阿里云oss token
export const getOssToken = () => {
  return request({
    method: 'post',
    url: '/api/oss/get_sts_token_for_oss_upload',
  });
};
// 查询用户列表
export const getUserList = (data: Record<any, any>) => {
  return request({
    method: 'post',
    url: '/api/user/list',
    data,
  });
};
// 刷新token
export const refreshToken = (data: { refreshToken: string }) => {
  return request({
    method: 'post',
    url: '/api/user/refresh',
    data,
  });
};
